//
//  Auction_SpecialSaleDetails_VC_WX.m
//  ZITHER
//
//  Created by weixin on 2019/5/30.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Auction_SpecialSaleDetails_VC_WX.h"
#import "Auction_SpecialSaleDetails_Tbv_WX.h"
#import "Auction_OfferPriceDone_View_WX.h"
#import "Auction_OfferPrice_View_WX.h"
#import "Auction_SpecialSaleBottmoV_View_WX.h"
#import "specialSaleSceneidDetails.h"


@interface Auction_SpecialSaleDetails_VC_WX ()

@property (nonatomic,strong)Auction_SpecialSaleDetails_Tbv_WX * tbv;
//@property (nonatomic,strong)Auction_OfferPriceDone_View_WX * backView;
@property (nonatomic,strong)Auction_OfferPrice_View_WX * backView;
@property (nonatomic,strong)Auction_SpecialSaleBottmoV_View_WX * bottom;
@property (nonatomic,strong)specialSaleSceneidDetails * model;

@end

@implementation Auction_SpecialSaleDetails_VC_WX

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNav];

}

-(void)setNav{
    [self.baseNavigationView NavigationBarStyle:1];
    self.baseNavigationView.navViewStyle.title.hidden = YES;
    self.baseNavigationView.navViewStyle.leftBtn.hidden = NO;
    self.baseNavigationView.navViewStyle.rightBtn.hidden = NO;
    [self.baseNavigationView.navViewStyle.rightBtn setTitle:@"分享" forState:UIControlStateNormal];
    [self.baseNavigationView.navViewStyle.rightBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    self.baseNavigationView.navViewStyle.leftBtn.backgroundColor = [UIColor whiteColor];

    @weakify(self);
    [[self.baseNavigationView.navViewStyle.rightBtn addTag]subscribeNext:^(id  _Nullable x) {
        @strongify(self);
        [self.backView show];
    }];
    
    self.baseNavigationView.navViewStyle.isShowShadow = NO;
    self.baseNavigationView.bottomLineView.hidden = YES;
    
    CGRect f =self.baseNavigationView.navViewStyle.rightBtn.frame;
    f.size.width = 50;
    f.size.height = 30;
    f.origin.y = f.origin.y-10;
    f.origin.x = f.origin.x-35;
    self.baseNavigationView.navViewStyle.rightBtn.frame =f;
    self.baseNavigationView.navViewStyle.rightBtn.centerY = self.baseNavigationView.navViewStyle.centerY+centerYH;
    
}

- (Auction_OfferPrice_View_WX *)backView{
    if (!_backView) {
//        _backView = [[Auction_OfferPriceDone_View_WX alloc]initWithFrame:CGRectMake(0,0, kScreenW, kScreenH)];
        _backView = [[Auction_OfferPrice_View_WX alloc]initWithFrame:CGRectMake(0,0, kScreenW, kScreenH)];
        _backView.State = OfferPriceNormal;
    }
    return _backView;
}

-(void)setDetailsId:(NSString *)DetailsId{
    _DetailsId = DetailsId;
    self.tbv.type = self.type;
    if (self.type == 0) {
        self.bottom.State = 0;
    }else{
        self.bottom.State = 1;
    }
    [self loadData];
    [self setUI];
}

-(void)loadData{
    [[serviceDefualt loadspecialSaleSceneid:self.DetailsId reponseObjctClass:[specialSaleSceneidDetails class]]subscribeNext:^(ResponseData * x) {
        if (x.success) {
//            [NSString convertToJsonData1:x.responseRawData];
            self.model = x.responseData;
        }else{
            [Tools showTips:x.errorInfo];
        }
    }];
}

-(void)setModel:(specialSaleSceneidDetails *)model{
    _model = model;
    self.tbv.model = model;
    [self.tbv reloadData];
}

-(void)setUI{
    [self.tbv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(NaviHeight);
        make.left.right.equalTo(self.view).offset(0);
        make.bottom.equalTo(self.view).offset(-65-kBottomSafeHeight);
    }];
    [self.bottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view).offset(0);
        make.height.mas_equalTo(65+kBottomSafeHeight);
        make.bottom.equalTo(self.view).offset(0);
    }];
}


-(Auction_SpecialSaleDetails_Tbv_WX *)tbv{
    if (!_tbv) {
        _tbv = [[Auction_SpecialSaleDetails_Tbv_WX alloc]initializeFrame:CGRectZero isMj:2 isEstimatedRowHeight:YES addRegisterNib:@[@"Auction_SpecialSaleDetailsUserInfo_Cell_WX",@"Auction_SpecialSaleDetailsPrice_Cell_WX",@"Auction_SpecialSaleDetailsHongKongPrice_Cell_WX",@"Auction_SpecialSaleDetailsPreferentialPrice_Cell_WX",@"Auction_SpecialSaleDetailsWatchInfo_Cell_WX",@"Auction_SpecialSaleDetailsWatchInfoSpecific_Cell_WX"]];
        [self.view addSubview:_tbv];
    }
    return _tbv;
}

-(Auction_SpecialSaleBottmoV_View_WX *)bottom{
    if (!_bottom) {
        _bottom = [[Auction_SpecialSaleBottmoV_View_WX alloc]init];
        _bottom.backgroundColor = [UIColor redColor];
        [self.view addSubview: _bottom];
        _bottom.State = 0;
        [[_bottom addTag]subscribeNext:^(id  _Nullable x) {
            _bottom.State =  _bottom.State+1;
        }];
    }
    return _bottom;
}

@end
